/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tnmk.worktime.gui.widget;

import javax.swing.JFrame;
import org.tnmk.worktime.gui.utils.WindowUtils;

/**
 *
 * @author tnmkhoi
 */
public class AboutDialog extends javax.swing.JPanel implements PopupPanel {

  PanelPopup popup;

  public AboutDialog(JFrame parent) {
    initComponents();
    popup = new PanelPopup(parent, this);
    popup.setLocation(WindowUtils.getCenterX(this), WindowUtils.getCenterY(this));
  }

  public void show() {
    popup.show();
  }

  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form
   * Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jtxtMessage = new javax.swing.JTextArea();
    jcompClose = new javax.swing.JLabel();

    setBackground(new java.awt.Color(51, 51, 51));
    setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 2, new java.awt.Color(179, 179, 179)), javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));
    addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        formMouseClicked(evt);
      }
    });

    jLabel1.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(204, 204, 204));
    jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/Product_Gray_80.png"))); // NOI18N
    jLabel1.setText(" Daily Record");

    jtxtMessage.setEditable(false);
    jtxtMessage.setBackground(new java.awt.Color(204, 204, 204));
    jtxtMessage.setColumns(20);
    jtxtMessage.setLineWrap(true);
    jtxtMessage.setRows(5);
    jtxtMessage.setText("\nVersion: 3.0\n + BufferStorage\n + Spend Statistic (with ID)\n + Add/Remove Session/Spend");
    jtxtMessage.setWrapStyleWord(true);
    jtxtMessage.setBorder(null);
    jtxtMessage.setDisabledTextColor(new java.awt.Color(0, 0, 0));
    jScrollPane1.setViewportView(jtxtMessage);

    jcompClose.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jcompClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/form/close_btn.png"))); // NOI18N
    jcompClose.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        jcompCloseMouseClicked(evt);
      }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jcompClose))
      .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1))
          .addComponent(jcompClose))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
        .addContainerGap())
    );
  }// </editor-fold>//GEN-END:initComponents

  private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
    if (evt.getClickCount() >= 2) {
      this.popup.hide();
    }
  }//GEN-LAST:event_formMouseClicked

  private void jcompCloseMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jcompCloseMouseClicked
    // TODO add your handling code here:
    this.popup.hide();
  }//GEN-LAST:event_jcompCloseMouseClicked


  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JLabel jLabel1;
  private javax.swing.JScrollPane jScrollPane1;
  private javax.swing.JLabel jcompClose;
  private javax.swing.JTextArea jtxtMessage;
  // End of variables declaration//GEN-END:variables

  @Override
  public void setPopup(PanelPopup popup) {
    this.popup = popup;
  }
}
